{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-10-10T08:37:22.090827Z",
     "start_time": "2025-10-10T08:37:22.087641Z"
    }
   },
   "source": [
    "l = [1, 2, 3, 4, 5, 6, 7]\n",
    "for index, item in enumerate(l):\n",
    "    if index < 3:\n",
    "        print(item)\n",
    "# for 循环 continue\n",
    "# for name, price in nam_price.items():\n",
    "#     if price >= 1000:\n",
    "#         continue\n",
    "#     if name not in name_color:\n",
    "#         print('name:{},color：{}'.format(name, 'None'))\n",
    "#         continue\n",
    "#     for color in name_color[name]:\n",
    "#         if color == 'red'\n",
    "#            continue\n",
    "#         print('name: {}, color: {}'.format(name, color))\n",
    "# while True:\n",
    "#     try:\n",
    "#         text = input('Please enter your questions, enter \"q\" to exit')\n",
    "#         if text == 'q':\n",
    "#             print('Exit system')\n",
    "#             break\n",
    "#     except Exception as err:\n",
    "#         print('Encountered error: {}'.format(err))\n",
    "#         break\n",
    "# 简便写法\n",
    "text = ' Today,  is, Sunday'\n",
    "text_list = [s.strip() for s in text.split(',') if len(s.strip()) > 3]\n",
    "print(text_list)"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "['Today', 'Sunday']\n"
     ]
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "92833a7fd070892a"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
